#version 1; November 2025
#Assumes laser has been connected with it.connect(x,9600)
#Requires PPCL700 (or PPCL550)
#Run with: it.script("examples\\PerformCleanJumpCalibration.txt")
#---- Settings
STARTFREQUENCY=194.56 #THz
CHANNELSPACING = 45 #GHz
NUMBEROFCHANNELS=10
POWER=13.2 #dBm
#-----

import time

it.resena(mr=1)  #reset the unit
time.sleep(3)    #wait a couple of seconds
it.fcf1(int(STARTFREQUENCY))
it.fcf2(10000*(STARTFREQUENCY-int(STARTFREQUENCY)))

it.pwr(int(POWER*100))

it.grid(CHANNELSPACING*10)

it.cleanJumpCalibrate(NUMBEROFCHANNELS)

currentchannel=0
while it.cleanJumpCalibrate()[1]&0x8000:
    time.sleep(5)
    #in the current firmware version, having a communication while the unit is saving the settings will result in an error. Therefore we are limiting the number of communications
print("calibration completed")

print("Performed cleanjump calibration for %d channels" %NUMBEROFCHANNELS)